package jedis;

import org.apache.commons.lang.StringUtils;
import redis.clients.jedis.Jedis;

/**
 * Created by zhangjinxia on 2017/10/12.
 */
public class Redis {

    public static void lpush(String key, String value){
        Jedis jedis = RedisUtil.getJedis();
        jedis.lpush(key, StringUtils.isEmpty(value) ? "" : value);
        RedisUtil.returnResource(jedis);
    }

    public static void hset(String key, String field, String value){
        Jedis jedis = RedisUtil.getJedis();
        jedis.hset(key, field, StringUtils.isEmpty(value) ? "" :value);
        RedisUtil.returnResource(jedis);
    }

    public static String hget(String key, String field){
        Jedis jedis = RedisUtil.getJedis();
        String val = jedis.hget(key, field);
        RedisUtil.returnResource(jedis);
        return val;
    }

    public static void del(String key){
        Jedis jedis = RedisUtil.getJedis();
        jedis.del(key);
        RedisUtil.returnResource(jedis);
    }

    public static void lrem(String key, long count, String value){
        Jedis jedis = RedisUtil.getJedis();
        jedis.lrem(key, count, value);
        RedisUtil.returnResource(jedis);
    }

}
